month_name_gene <- function(currentyear = 2022, currentmonth = 8, back_unit = 7, systime = F){
  if(systime){
    currentyear <- as.numeric(substr(as.character(Sys.Date()),1,4))
    currentmonth <- as.numeric(substr(as.character(Sys.Date()),6,7))
  }
  dates_vec <- c()
  dates_end <- c()
  count <- 1
  while(count <= back_unit){
    dates_vec <- c(dates_vec, as.Date(paste(currentyear, "-",currentmonth, "-01", sep ="")))
    if(currentmonth != 12){
      dates_end <- c(dates_end, (as.Date(paste(currentyear, "-",currentmonth + 1, "-01", sep =""))-1))
    }else{
      dates_end <- c(dates_end, (as.Date(paste(currentyear, "-01-01", sep ="")) - 1))
    }
    count <- count + 1
    currentmonth <- currentmonth - 1
    if(currentmonth == 0){
      currentmonth <- 12
      currentyear <- currentyear - 1
    }
  }
  
  dates_vec <- as.Date("1970-01-01") + dates_vec
  dates_vec <- dates_vec[order(dates_vec)]
  dates_end <- as.Date("1970-01-01") + dates_end
  dates_end <- dates_end[order(dates_end)]
  return(list(dates_vec, dates_end))
}